package com.lyj.validates.utils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

/**
 * 日期工具类
 * @author:liyajie
 * @createTime:2022/1/20 10:18
 * @version:1.0
 */
public class DateUtil {


    public static String YYYY_MM_DD = "yyyy-MM-dd";

    public static String YYMMDD = "yyMMdd";

    public static String YYYYMMDD = "yyyyMMdd";

    public static String YYYYMM = "yyyyMM";

    public static String YYYY_MM_DDHHMMSS = "yyyy-MM-dd HH:mm:ss";

    public static String YYYYMMDDHHMMSS2 = "yyyyMMdd HH:mm:ss";

    // yyyy-MM-dd HH:mm
    public static String YYYY_MM_DDHHMM = "yyyy-MM-dd HH:mm";

    public static String YYYYMMDDHHMMSS = "yyyyMMddHHmmss";

    /*HH:mm:ss*/
    public static String HHMMSS = "HH:mm:ss";

    /*HHmmssSSS*/
    public static String HHMMSSSSS = "HHmmssSSS";

    /*MMddHHmmssSSS*/
    public static String MMddHHmmssSSS = "MMddHHmmssSSS";

    /*yyyyMMddHHmmssSSS*/
    public static String YYYYMMDDHHMMSSSSS = "yyyyMMddHHmmssSSS";

    /**缺省月格式*/
    public static final String DEFAULT_MONTH = "MONTH";

    /**缺省年格式*/
    public static final String DEFAULT_YEAR = "YEAR";

    /**缺省日格式*/
    public static final String DEFAULT_DATE = "DAY";

    /**缺省小时格式*/
    public static final String DEFAULT_HOUR = "HOUR";

    /**缺省分钟格式*/
    public static final String DEFAULT_MINUTE = "MINUTE";

    /**缺省秒格式*/
    public static final String DEFAULT_SECOND = "SECOND";

    /**缺省秒格式*/
    public static final String EXP_DATE = "20991231235959";

    /**
     * 格式化当前日期
     * @author: liyajie
     * @date: 2022/1/20 10:47
     * @param dateFormat
     * @return java.lang.String
     * @exception:
     * @update:
     * @updatePerson:
     **/
    public static String format2String(String dateFormat) {
        return new SimpleDateFormat(dateFormat).format(new Date());
    }

    /**
     * 转换指定格式的字符串为时间
     * @author: liyajie
     * @date: 2022/1/20 10:47
     * @param str
     * @param pattern
     * @return java.util.Date
     * @exception:
     * @update:
     * @updatePerson:
     **/
    public static Date formatStr2Date(String str, String pattern) {
        Date d = null;
        if (null != str && !str.trim().equals("")) {
            SimpleDateFormat sdf = new SimpleDateFormat(pattern);
            try {
                d = sdf.parse(str);
            } catch (ParseException e) {
                throw new RuntimeException(e);
            }
        }
        return d;
    }




}
